<%@page import="com.liferay.portal.theme.ThemeDisplay"%>
<%@page import="com.crossriver.crgis.database.service.persistence.Application_C_of_OUtil"%>
<%@page import="com.crossriver.crgis.database.model.Application_C_of_O"%>
<%@page import="com.crossriver.crgis.database.model.Contact_Information"%>
<%@ page import="com.crossriver.crgis.cofo.util.ApplicationCofOConstants" %>
<%@taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>

<%@ include file="/init.jsp"%>


<%
Contact_Information contactInfo =
		(Contact_Information)request.getAttribute(
					ApplicationCofOConstants.IND_CONTACT_SESSION_ATTR);
Application_C_of_O applicatn = 
	Application_C_of_OUtil.findByPrimaryKey(contactInfo.getApplicationId());
%>

<liferay-portlet:actionURL name="saveContactInformation" var="saveContactInformation"></liferay-portlet:actionURL>

 <aui:form action="<%=saveContactInformation.toString() %>" method="post" name="saveContactInformation_fm">
  <% String app = applicatn.getApplication(); %>
 <div id="main">
	<%
	if("certification".equalsIgnoreCase(app)){
	%>
	<h1>Application for Certificate Of Occupancy</h1>
	<%
	}else if("re-certification".equalsIgnoreCase(app)){
	%>
	<h1>Application for Re-Certificate Of Occupancy</h1>
	<%
	}else {
	%>
	<h1>Application for State Land</h1>
	<%
	}
	%>
	
	<div class="content">
		<liferay-ui:error key="mobile-no-mandatory" message="mobile-no-mandatory" />
		<liferay-ui:error key="email-is-mandatory" message="email-is-mandatory" />
		<liferay-ui:error key="email-is-not-valid" message="email-is-not-valid" />
		<liferay-ui:success key="contact-information-save-success" message="contact-information-save-success"></liferay-ui:success>
		
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
			<td width="15%" valign="top">
				<aui:input name="applicationId" type="hidden" value="<%= contactInfo.getApplicationId() %>"></aui:input>
				<aui:input name="buttonClicked" type="hidden" value=""></aui:input>
				<table width="100%" id="steps" cellpadding="0" cellspacing="0">
       		<tr><td valign="middle" align="center">STEP 1</td></tr>
       		<tr><td valign="middle" align="center">STEP 2</td></tr>
	        <tr><td valign="middle" align="center" class="current">STEP 3</td></tr>
          <tr><td valign="middle" align="center">STEP 4</td></tr>
          <tr><td valign="middle" align="center">STEP 5</td></tr>
          <tr><td valign="middle" align="center">STEP 6</td></tr>
          <tr><td valign="middle" align="center">STEP 7</td></tr>
          <tr><td valign="middle" align="center">STEP 8</td></tr>                               
       	</table>
			</td>
			<td width="85%" valign="top">
				<table width="100%" id="mainform">
        	<tr>
         		<td class="title" colspan="3">Contact Information</td>
					</tr>
					<tr>
           	<td align="right" class="buttons">
							<aui:input name="applicationId" type="hidden" value="<%= contactInfo.getApplicationId() %>"></aui:input>
							<hr>
           		<aui:button type="button" value="Exit Application" onClick="exitApplication();"></aui:button>
             	
              
             	<aui:button type="submit" value="Save" onClick="setButtonClicked('btnSave');" ></aui:button>
            	<aui:button type="submit" value="Save and Continue" onClick="setButtonClicked('btnSaveAndContinue');" ></aui:button>
             	<aui:button type="button" value="Cancel Application" onClick="confirmPost()"></aui:button>
           	</td>
					</tr>
					<tr>
						<td><br>
           		<aui:input label="Mobile Phone<span class='mandatoryfld'>*</span>" 
	            	inlineLabel=""
	            	name="phoneMobile"
	            	value="<%= contactInfo.getPhoneMobile() %>"
	            	helpMessage="">
	          	</aui:input>
            </td>
         	</tr>
         	<tr>
            <td><br>	
           		<aui:input label="Office Phone" name="phoneOffice" 
	             	value="<%= contactInfo.getPhoneOffice() %>">
	          	</aui:input>
            </td>
          </tr>
         	<tr>
            <td><br>		
             	<aui:input label="House Phone" 
	            	value="<%= contactInfo.getPhoneHome() %>"
	             	name="phoneHome">
	          	</aui:input>
						</td>
					</tr>
					<tr>
						<td ><br>
						<aui:input helpMessage="Provide Your Email Address<span class='mandatoryfld'>*</span>"
							label="Email Address<span class='mandatoryfld'>*</span>" name="emailAddress" 
							value="<%= contactInfo.getEmailAddress() %>"
							style="width:300px"></aui:input>
						</td>
					</tr>
<!-- 					<tr> -->
<!-- 						<td><br> -->
<%-- 						<aui:input helpMessage="" label="P. O. Box Address" --%>
<%-- 							value="<%= contactInfo.getPoBox() %>" --%>
<%-- 							name="poBoxAddress" style="width:300px"></aui:input></td> --%>
<!-- 					</tr> -->
					<tr>
						<td><br>
						<aui:input helpMessage="" label="Fax" name="fax"
							value="<%= contactInfo.getFax() %>"
							style="width:200px"></aui:input></td>
					</tr>
					<tr>
						<td><br>
						<hr>
						<p><strong>All fields asterisk in "Red" are
						compulsory</strong></p>
						<p>You are responsible for providing correct phone numbers and
						addresses. Phone numbers must include area codes and addresses
						must include zip codes.</p>
						<p>If you are not sure of an address, check it by personal
						verification. Your local library may have a directory service or
						copies of local phone directories. If any phone numbers or
						addresses change, including your own, you must notify the Ministry
						Of Lands & Housing of those changes.</p>
						</td>
					</tr>
          <tr>
            <td align="right">
            	<hr>
            	<aui:button type="button" value="Exit Application" onClick="exitApplication();"></aui:button>
             	
              
             	<aui:button type="submit" value="Save" onClick="setButtonClicked('btnSave');" ></aui:button>
            	<aui:button type="submit" value="Save and Continue" onClick="setButtonClicked('btnSaveAndContinue');" ></aui:button>
             	<aui:button type="button" value="Cancel Application" onClick="confirmPost()"></aui:button>
            </td>
          </tr>
				</table>

				</td>
			</tr>
		</table>
		</td>
	</tr>
</table>
</div>
</div>
  	<script type="text/javascript">
	function setButtonClicked(id)
	{
	    //alert(id);
	   document.<portlet:namespace/>saveContactInformation_fm.<portlet:namespace/>buttonClicked.value=id;
	  // alert(document.<portlet:namespace/>quick_add_account_fm.<portlet:namespace/>buttonClicked.value);
	    //document.getElementById('jspPage').value=id;
	}

	function selectOptions()
	{
	   // alert(id);
	   document.<portlet:namespace/>saveContactInformation_fm.<portlet:namespace/>houseNo.value='<%= contactInfo.getEmailAddress() %>';
	   document.<portlet:namespace/>saveContactInformation_fm.<portlet:namespace/>addressline1.value='<%= contactInfo.getPhoneMobile() %>';
	  	 }

	selectOptions();
	
	</script>
</aui:form>

	<liferay-portlet:actionURL name="exitApplication" var="exitApplication"></liferay-portlet:actionURL>
	<form name="<portlet:namespace/>exitApplication_fm" method="post"	id="<portlet:namespace/>exitApplication_fm" action="<%=exitApplication.toString()%>"></form>
	<script type="text/javascript">
	<!--
	function exitApplication()
	{
		document.forms["<portlet:namespace/>exitApplication_fm"].submit();
	}
	//-->
	</script>
	
	
<script type="text/javascript">
<!--
	function confirmPost()
	{
	var agree=confirm("Cancelling the process will delete the record you have entered into the portal for this application. Do you want to proceed?");
	if (agree){
		document.forms["<portlet:namespace/>deleteApplication_fm"].submit();
		return true ;
	}
	else{
		return false ;
	}
	}
//-->
</script>

<liferay-portlet:actionURL name="deleteApplication" var="deleteApplication"></liferay-portlet:actionURL>
 <aui:form action="<%=deleteApplication.toString() %>" method="post" name="deleteApplication_fm">
  	<aui:input name="applicationId" type="hidden" value="<%= contactInfo.getApplicationId() %>"></aui:input>
 </aui:form>
 
 